Clock
, which handles timing and
synchronization. The programmer can simply use these core
classes and specialize them to fit particular needs. The
ScriptX core classes are described in the ScriptX Components
Guide and the ScriptX Class Reference.
Being a rooted language, ScriptX was designed with the core
classes library in mind. It therefore has many language
constructs that know about and incorporate the methods that
all objects are expected to have. The result is that ScriptX
has multiple surface syntax; in other words, it often has more
than one way to express the same thing. These alternate ways
of expressing something, which are in many cases shortcuts for
longer operations that use methods, are especially important
in the areas of object creation and operator syntax. For
example, StringConstant
and Array
are two core classes where shortcut language constructs can be
used to create an instance of the class. By just entering the
data which comprises a StringConstant
object, you
create a StringConstant
object. Similarly, just
entering the contents of an array in array form creates an
Array
object. The following are some examples
showing both the shortcut language syntax and the
corresponding longer version using method syntax:
Language Syntax |
Equivalent Method Syntax |
---|---|
"I am a string" | new StringConstant \ |
global ar := #(1, 2) | global ar := new Array |
global kl := #(1:"one", 2:"two") | global kl := new KeyedLinkedList |
The examples below demonstrate using operator syntax and array access, which are shorter and more natural than using the equivalent method syntax:
Operator Syntax |
Equivalent Method Syntax |
---|---|
2 + 3 | sum 2 3 |
5 * 4 | mul 5 4 |
ar[1] | getOne ar 1 |
ar[1] := 2 | setOne ar 1 2 |
This document is part of the ScriptX Language Guide, one of the volumes of the ScriptX Technical Reference Series. ScriptX is developed by the ScriptX Engineering Team at Apple Computer, successor to the Kaleida Engineering Team at Kaleida Labs, Inc.